/*
 * test_Adapter.c
 *
 *  Created on: 2011-11-20
 *      Author: Jesse Meng [pingf0@gmail.com]
 */

//CLASS(Adaptee){
//	char * name;
//	STATIC(Adaptee);
//	cPtFn doAction;
//};
//int Adaptee_reload(Adaptee *self,char *p){
//	if(NULL==p) self->name="anonymous";
//	else self->name=p;
//	return 0;
//}
//int Adaptee_reloadSt(StAdaptee *self,void *p){
//	char * doAction(Adaptee *self){
//		return self->name;
//	}
//	self->doAction=(void *)doAction;
//	return 0;
//}
//ASM(Adaptee,Adaptee_reload,NULL,Adaptee_reloadSt,NULL);
//
//CLASS(Adapter){
//	Adaptee * adaptee;
//	STATIC(Adapter);
//	cPtFn request;
//	iFn print;
//};
//int Adapter_reload(Adapter *self,Adaptee *p){
//	self->adaptee=p;
//	return 0;
//}
//int Adapter_unload(Adapter *self,Adaptee *p){
//	return DELETE0(p);
//}
//int Adapter_reloadSt(StAdapter *self,void *p){
//	char * request(Adapter *self){
//		return STT(self->adaptee,Adaptee)->doAction(self->adaptee);
//	}
//	self->request=(void *)request;
//	int print(Adapter *self){
//		printf("%s\n",STT(self,Adapter)->request(self));
//		return 0;
//	}
//	self->print=(void *)print;
//	return 0;
//}
//ASM(Adapter,Adapter_reload,NULL,Adapter_reloadSt,NULL);
#include "Adapter.h"
int main(int argc, char **argv) {
	Adapter *c1=NEW(Adapter,NEW(Adaptee,"Client 1"));
	Adapter *c2=NEW(Adapter,NEW(Adaptee,"Client 2"));
	StAdapter *f=(void*)ST(c1);
	f->print(c1);
	f->print(c2);
	DELETE0(c1);
	DELETE0(c2);
	return 0;
}
